package com.example.service.impl;

import com.example.mapper.FeedbackMapper;
import com.example.pojo.Feedback;
import com.example.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class FeedbackServiceImpl implements FeedbackService {
    @Autowired
    private FeedbackMapper feedbackMapper;
    @Override
    public void add(Feedback feedback) {
        feedback.setCreatedAt(LocalDateTime.now());
        feedbackMapper.add(feedback);
    }

    @Override
    public List<Feedback> list() {
        List<Feedback> list = feedbackMapper.list();
        return list;
    }

    @Override
    public void delete(Integer id) {
        feedbackMapper.delete(id);
    }

    @Override
    public Feedback detail(Integer id) {
        Feedback feedback = feedbackMapper.detail(id);
        return feedback;
    }

    @Override
    public void update(Feedback feedback) {
        feedback.setCreatedAt(LocalDateTime.now());
        feedbackMapper.update(feedback);
    }
}
